package main

func main() {
	tank := new(Player)
	tank.Name = "Canon"
	tank.Health = 300

	//----------------------------

	var version int = 1
	cmd := &Command{}
	cmd.Name = "version"
	cmd.Comment = "show version"
	cmd.Var = &version

	//------------------------------

	newCommand("version", &version, "show version")
	newCommandByName("version")
}

//实例化，类似构造函数
func newCommand(name string, varval *int, comment string) *Command {
	//return &Command{Name: name, Var: varval, Comment: comment}
	return &Command{name, varval, comment}
}

//初始化部分成员
func newCommandByName(name string) *Command {
	return &Command{Name: name}
}

type Player struct {
	Name   string
	Health int
	Magic  int
}

type Command struct {
	Name    string
	Var     *int
	Comment string
}
